﻿#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include "MarketService.h"
#include "FrameData.h"
#include "Tools.h"
#include <thread>
//#include "OrderTrader.h"
#include "MarketDataStream.h"
#include "CTPTime.h"

int main(int argc, char *argv[])
{
	//FoldOperator foldOper;
	MDIO::FrameData dataStream;
	// 非行情时间段直接退出 清空临时行情
	time_t ctTime = Tools::GetCurrentTimeStamp();
	CTPTm::HolidayManager pManager;
	if (!pManager.IsMarketTime(ctTime))
	{
		return 88;
	}
	MarketService order;
	for (;;)
	{
		if (!order.IsCTPConnected())
		{
			break;
		}
		std::list<FData::FrameKItem> frameList;
		dataStream.Get(frameList);
		if (!frameList.empty())
		{
			order.DealFrameDataList(frameList);
		}

		if (frameList.empty())
		{
			std::this_thread::sleep_for(std::chrono::milliseconds(500));
		}
	}
	
	return 0;
}